package demo1;

import java.util.HashSet;
import java.util.Set;
class Solution {
    public static void main(String[] args) {
        String s1 = " ";
        s1 += "hello";
        int[] arr = new int[10];
        StringBuffer s2 = new StringBuffer("helloworld");

        System.out.println(s1);
        System.out.println(s1.contains("h"));
        //System.out.println(lengthOfLongestSubstring("aab"));
    }
    public static int lengthOfLongestSubstring(String s) {
        Set<Character> set = new HashSet<>();
        int len = 0;
        for (int i = 0; i < s.length(); i++) {
            if (set.contains(s.charAt(i))) {
                if (set.size() > len) {
                    len = set.size();
                }
                i = i - set.size();
                set.clear();
                
            } else {
                set.add(s.charAt(i));
            }
        }
        if (len < set.size()) {
            len = set.size();
        }
        return len;
    }
}